/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2019-2021. All rights reserved.
 * Description: 上机编程题
 * Note: 缺省代码仅供参考，可自行决定使用、修改或删除
 */
#include <iostream>
#include <string>
#include <stack>
using namespace std;

class Solution {
private:

public:
    // 待实现函数，在此函数中填入答题代码;
    int CalcExpression(const string &expression) {
        stack<int> numbers;
        for (int i = 0; i < expression.size(); i++) {
            const char c = expression[i];
            //如果是逗号，跳过
            if (c == ',') continue;
            //如果不是数字，弹出两个数字，计算结果，再压入栈
            if (!isdigit(c)) {
                //需要考虑负数的情况
                if (i < expression.size() - 1 and isdigit(expression[i + 1])) {
                    numbers.push(0);
                    while (isdigit(expression[i + 1])) {
                        char next = expression[++i];
                        int tmp = numbers.top();
                        numbers.pop();
                        numbers.push(10 * tmp + next - '0');
                    }
                    int tmp = numbers.top();
                    numbers.pop();
                    numbers.push(-tmp);
                } else {
                    int right = numbers.top();
                    numbers.pop();
                    int left = numbers.top();
                    numbers.pop();
                    switch (c) {
                        case '+': numbers.push(left + right);
                            break;
                        case '-': numbers.push(left - right);
                            break;
                        case '*': numbers.push(left * right);
                            break;
                        case '/': numbers.push(left / right);
                            break;
                    }
                }
            } else {
                //如果是数字
                numbers.push(c - '0');
                //再判断是否是多位数
                while (isdigit(expression[i + 1])) {
                    char next = expression[++i];
                    int tmp = numbers.top();
                    numbers.pop();
                    numbers.push(10 * tmp + next - '0');
                }
            }
        }
        return numbers.top();
    }
};

inline string ReadLine() {
    string line;
    getline(cin, line);
    return line;
}

int main() {
    string expression = ReadLine();
    Solution solu;
    int result = solu.CalcExpression(expression);
    cout << result << endl;

    return 0;
}
